﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IAS.WEB.ViewModels;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Mvc;
using ServiceStack.OrmLite;

namespace IAS.WEB.Areas.Account.Controllers
{
    [Authenticate]    
    public class AuthenticateController : ServiceStackController
    {
        // GET: Account/Authenticate
        public ActionResult Index()
        {
            var session = SessionAs<AuthUserSession>();
            var response = new HomeViewModel { Session = session };
            if (response.Session.UserAuthId != null)
            {
                var userAuthId = int.Parse(response.Session.UserAuthId);
                response.UserAuths = Db.Select<UserAuth>(x => x.Id == userAuthId);
                response.UserAuthDetails = Db.Select<UserAuthDetails>(x => x.UserAuthId == userAuthId);
            }
            return View(response);
        }

        // GET: Account/Authenticate/Details/5
        public ActionResult Details(int id)
        {
            return View();
        }

        // GET: Account/Authenticate/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: Account/Authenticate/Create
        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Account/Authenticate/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: Account/Authenticate/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Account/Authenticate/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        // POST: Account/Authenticate/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
